/**
 * Created by Jay on 2016/7/8.
 */
function edit_pwd(){
    var username_r=sessionStorage.getItem("this_username");
    //console.log("username",username);
    var version_pwd=$("#edit_pwd").Validform({
        btnSubmit:".edit_pwd_btn",
        tiptype:3,
        label:".label",
        showAllError:true,
        datatype:{
            //"user_n":/^6-20,[a-z|A-Z|0-9|_]$/,
            "num":/^[0-9]*$/
        },
        ajaxPost:true
    });//表单验证
    //console.log(version_pwd);
    version_pwd.tipmsg.w["user_n"]="请输入6到20个英文加数字字符";
    version_pwd.addRule([
        {
            ele:".inputxt:eq(0)",
            datatype:"*"
        },
        {
            ele:".inputxt:eq(1)",
            datatype:"*6-20"
        },
        {
            ele:".inputxt:eq(2)",
            datatype:"*6-20",
            recheck:"userpassword"
        }
    ]);
    mccmsa.ajax({
            url:"user/getUserAll",
            method:"GET",
            data: {pageNo:1,pageSize:10},
            success: function (data) {
                //console.log(data);
                for(var i=0;i<data.result.resultList.length;i++){
                    console.log(1);
                    console.log(username_r);
                    if(username_r==data.result.resultList[i].username){
                        console.log(username_r);
                        var data_id=data.result.resultList[i].id;
                        //console.log(data.result.resultList[i].id)
                        //console.log("data_id");
                        //console.log(data_id);
                        $(".edit_pwd_btn").on("click",function(){
                            mccmsa.ajax({
                                url: "user/updateUserSafe",
                                method: "POST",
                                data: {id:data_id,username:username_r,password:$("#edit_pwd_t").val(),authPassword:$("#edit_username").val()},
                                success: function (data) {
                                    //console.log(data);
                                    if(data.status!=200){
                                        layer.alert(data.message);
                                        return;
                                    }else{
                                        layer.alert(data.message);
                                    }
                                }
                            })
                        })
                    }else{
                        console.log("error");
                    }
                }
            }
    })
    //console.log("this_username:"+username);
    //$("#edit_username").val(username).attr("disable","disable");

}